{extend name="layout" /}
{block name="content"}
<form class="layui-form" lay-filter="LAY-app-project-issue-form" id="LAY-app-project-issue-form">
    <div class="layui-form-item">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-block">
            <input type="radio" name="type" value="0" title="任务" checked="" lay-filter="issue_type">
            <input type="radio" name="type" value="1" title="需求" lay-filter="issue_type">
            <input type="radio" name="type" value="2" title="缺陷" lay-filter="issue_type">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-inline">
            <input type="text" name="title" value="{$issue.title|default=''}" lay-verify="required"
                       placeholder="请输入..." autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">进度</label>
        <div class="layui-input-inline">
            <input type="number" name="progress" lay-verify="required" value="{$issue.progress|default=0}" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <select name="status">
                <option value="0">待办的</option>
                <option value="1">进行中</option>
                <option value="2">已完成</option>
                <option value="3">已拒绝</option>
                <option value="4">已确认</option>
                <option value="5">设计中</option>
                <option value="6">开发中</option>
                <option value="7">已验收</option>
                <option value="8">修复中</option>
                <option value="9">已取消</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">负责人</label>
        <div class="layui-input-inline">
            <select name="accept">
                <option value="0">请选择负责人</option>
                <option value="1">admin</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">开始日期</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="laydate-start" name="start_time" placeholder="开始日期" value="{$issue.start_time|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">截止日期</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="laydate-end" name="end_time" placeholder="截止日期" value="{$issue.end_time|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">预计工时</label>
        <div class="layui-input-inline">
            <input type="number" name="hour" class="layui-input" placeholder="1" value="{$issue.hour|default=1}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <textarea name="content" placeholder="请输入" class="layui-textarea">{$issue.content|default=''}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-app-project-issue-submit" id="LAY-app-project-issue-submit" value="确认">
    </div>
</form>
{/block}
{block name="js"}
<script>
    layui.use(['laydate'], function(){

        var $ = layui.$, form = layui.form;
        // 根据值设置选中
        $("input[name='type'][value='{$issue.type|default=0}']").attr("checked",true);
        $("select[name='status'] option[value={$issue.status|default=0}]").attr("selected",true);
        $("select[name='accept'] option[value={$issue.accept|default=0}]").attr("selected",true);
        form.render();

        var laydate = layui.laydate;

        //开始日期
        var insStart = laydate.render({
            elem: '#laydate-start'
            ,min: 0
            ,done: function(value, date){
                //更新结束日期的最小日期
                insEnd.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });

                //自动弹出结束日期的选择器
                insEnd.config.elem[0].focus();
            }
        });

        //结束日期
        var insEnd = laydate.render({
            elem: '#laydate-end'
            ,min: 0
            ,done: function(value, date){
                //更新开始日期的最大日期
                insStart.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });
    });
</script>
{/block}